package my.dict.v01;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Stack;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class History extends Activity {

		ListView lv;
		Stack<String> stackHistory;
		int currentSize;
	
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			//setContentView(R.layout.history);
			
			setContentView(R.layout.history);

			lv = (ListView)findViewById(R.id.listview_history);
			
		}
		
		public void onResume() {
			
			super.onResume();
			
			stackHistory = Wordlist.stackHistory;
			currentSize = stackHistory.size();
			
			Log.d(Main.logcat, "Number of items in History stack: " + currentSize);
			
			//Object[] objs = (Object[]) stackHistory.toArray();
			
//			List<String> words = new ArrayList<String>();
			String[] words = 		
				Arrays.asList(stackHistory.toArray()).toArray(new String[stackHistory.toArray().length]);
			
	        TextView textview = (TextView) findViewById(R.id.textview_history);
	        textview.setText(currentSize + " most recent words:");
	        //setContentView(textview);		        
			
	        //if(words.length > 0)
	        	lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, words));  
			
		}


}
